package net.lcheng.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import net.lcheng.commons.utils.PageList;
import net.lcheng.dao.WxShopUserMapper;
import net.lcheng.model.WxShopUser;
import net.lcheng.model.WxShopUserExample;
import net.lcheng.service.WxShopUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by zwr on 2016/7/5 0005.
 */
@Service
public class WxShopUserServiceImpl implements WxShopUserService {
   @Resource
   WxShopUserMapper mapper;
    @Override
    public PageList<WxShopUser> getWxShopUsevByShopid(int pageIndex, int pageSize, Integer shopId) {
        PageHelper.startPage(pageIndex,pageSize);
        WxShopUserExample example=new WxShopUserExample();
        example.or().andShopIdEqualTo(shopId);
        List<WxShopUser> list =  mapper.selectByExample(example);
        PageInfo pageInfo = new PageInfo(list);
        PageList pageList = new PageList<WxShopUser>();
        pageList.list = pageInfo.getList();
        pageList.totalCount = pageInfo.getTotal();
        pageList.totalPage=pageInfo.getPages();
        pageList.pageIndex=pageInfo.getPageNum();
        pageList.pageSize=pageInfo.getPageSize();
        return pageList;
    }

    @Override
    public List<WxShopUser> getWxShopUsevByUserName( String userName,Integer shopId) {
        WxShopUserExample example=new WxShopUserExample();
        example.or().andUserNameEqualTo(userName).andShopIdEqualTo(shopId);
        return mapper.selectByExample(example);
    }
}
